<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<title>Single</title>
<link href="/Public/Home/css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->

<!-- Custom Theme files -->
<!--theme-style-->
<link href="/Public/Home/css/style.css" rel="stylesheet" type="text/css" media="all" />	
<!--//theme-style-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<script type="text/javascript" src="/Public/static/jquery-2.0.3.min.js"></script>
<script type="text/javascript">
$(function(){	
	$("select").change(function(){
      var gid = <?php echo ($list[0]["id"]); ?>;
      var attr = new Array();	
      $("select").each(function(i,el){
      	attr.push($(el).val());
      });
      attr.sort(function(a,b){
      	return a-b;
      });
      // alert(attr);die;
   $.post("<?php echo U('ajax');?>", { gid:gid, attr: attr },
   function(date){
     $('#price').html(date.mprice);
     $('#num').html(date.num);
     $('#ark_buyqn').val(1);
     $('.g-total-price').html(date.mprice);
   });
	});
})









</script>

				<script type="text/javascript">
					jQuery(document).ready(function($) {
						$(".scroll").click(function(event){		
							event.preventDefault();
							$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
						});
					});
				</script>

<script>$(document).ready(function(c) {
	$('.alert-close').on('click', function(c){
		$('.message').fadeOut('slow', function(c){
	  		$('.message').remove();
		});
	});	  
});
</script>
<script>$(document).ready(function(c) {
	$('.alert-close1').on('click', function(c){
		$('.message1').fadeOut('slow', function(c){
	  		$('.message1').remove();
		});
	});	  
});
</script>
</head>
<body>
  <!--header-->
	<div class="header">
		<div class="header-top">
			<div class="container">	
			<div class="header-top-in">			
				<div class="logo">
					<a href="index.html"><img src="/Public/Home/images/logo.png" alt=" " ></a>
				</div>
				<div class="header-in">
					<ul class="icon1 sub-icon1">
							<li  ><a href="wishlist.html">WISH LIST (0)</a> </li>
							<li  ><a href="account.html">  MY ACCOUNT</a></li>
							<li ><a href="#" > SHOPPING CART</a></li>
							<li > <a href="checkout.html" >CHECKOUT</a> </li>	
							<li><div class="cart">
									<a href="<?php echo U('Cart/index',array('id'=>$list[0]['id']));?>" class="cart-in"> </a>
									<span id="cartnum"><?php echo ($count); ?></span>
								</div>
								
							</li>
						</ul>
				</div>
				<div class="clearfix"> </div>
			</div>
			</div>
		</div>
		<div class="header-bottom">
		<div class="container">
			<div class="h_menu4">
				<a class="toggleMenu" href="#">Menu</a>
				<ul class="nav">
					<li class="active"><a href="index.html"><i> </i>Desktops</a></li>
					<li ><a href="#" >Laptops & Notebooks</a>
						<ul class="drop">
							<li><a href="products.html">Sony(2)</a></li>
							<li><a href="products.html">Android(4)</a></li>
							<li><a href="products.html">Apple(7)</a></li>
							<li><a href="products.html">Acer(53)</a></li>
							<li><a href="products.html">HP(78)</a></li>
							<li><a href="products.html">Intel(5)</a></li>
						</ul>
						</li> 						
						<li><a href="products.html" >  Tablets</a></li>            
						<li><a href="products.html" >Components</a></li>						  				 
						<li><a href="products.html" >Software</a></li>
						<li><a href="products.html" >Phones & PDAs </a></li>
						<li><a href="products.html" >  Cameras  </a></li>
						<li><a href="contact.html" >Contact </a></li>
					
				</ul>
				<script type="text/javascript" src="/Public/Home/js/nav.js"></script>
			</div>
		</div>
		</div>
		<div class="header-bottom-in">
		<div class="container">
		<div class="header-bottom-on">
			<p class="wel"><a href="#">Welcome visitor you can login or create an account.</a></p>
			
			<div class="clearfix"></div>
		</div>
		</div>
		</div>
	</div>
	<!---->
		<div class="container">
			<div class="single">
				<div class="col-md-9 top-in-single">
					<div class="col-md-5 single-top">	
						<!-- start product_slider -->
				    <div class="flexslider">
							        <!-- FlexSlider -->
										<script src="/Public/Home/js/imagezoom.js"></script>
										  <script defer src="/Public/Home/js/jquery.flexslider.js"></script>
										<!-- <link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" /> -->

										<script>
										// Can also be used with $(document).ready()
										$(window).load(function() {
										  $('.flexslider').flexslider({
											animation: "slide",
											controlNav: "thumbnails"
										  });
										});
										</script>
									<!-- //FlexSlider-->

							  <ul class="slides">
								<li data-thumb="images/si1.jpg">
									<div class="thumb-image"> <img style="width:400px;height:350px" src="<?php echo ($list[0]["pic"]); ?>" data-imagezoom="true" class="img-responsive"> </div>
								</li>
								
							  </ul>
							<div class="clearfix"></div>
					</div>
				<!-- end product_slider -->

					</div>	
					<div class="col-md-7 single-top-in">
						<div class="single-para">
						<?php if(is_array($cate)): $i = 0; $__LIST__ = $cate;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><h1><?php echo ($v["title"]); ?></h1><?php endforeach; endif; else: echo "" ;endif; ?>
							<div class="para-grid">
								<span  class="add-to" id="price"><?php echo ($price["mprice"]); ?></span><br>
								<!-- <a href="#"> --><span style="margin-left:300px;margin-top:-20px" class="hvr-shutter-in-vertical cart-to" id="addcart">加入购物车</span><!-- </a> -->
													
								<div class="clearfix"></div>
							 </div>
							<h5><?php echo ($list[0]["name"]); ?></h5>
							<div class="available">
								<h6>属性值下选框</h6>
								<ul>

									<li>
									<?php if(is_array($attr)): $i = 0; $__LIST__ = $attr;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i; echo ($v["name"]); ?>
										<select name="" id="">
											<?php if(is_array($v["val"])): $i = 0; $__LIST__ = $v["val"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vv): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vv["id"]); ?>"><?php echo ($vv["value"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
										</select><?php endforeach; endif; else: echo "" ;endif; ?></li>
								库存：<li id="num"><?php echo ($price["num"]); ?></li>
							</ul>

						</div>
						<div class="proinfo-num" style="margin-top: 20px;">
                                                                <div class="dt">
                                                                    购买数量</div>
                                                                    <button type="button" style="text-align: center;font-size: 15px; width: 20px;height: 30px;line-height: 20px;" id="gnumjian">-</button>
                                                            

                                                                    <input id="ark_buyqn" 
                                                                           value="1" name="GoodsNum9788" style="width:30px;text-align: center;height: 25px;">

                                                              
                                                                    <button type="button" style="text-align: center;font-size: 15px; width: 20px;height: 30px;line-height: 20px;" id="gnumjia">+</button>

                                                            </div>
<div class="form4_infoMin4" id="ark_goodsdynamic" gprice="25.00"
gpoints="25">
<span class="totalPrice totalinfo">总价：￥<i class="g-total-price"><?php echo ($price["mprice"]); ?></i>元</span>

                                                           

                                                            <p class="g-msg">
</p>                                                         </div>
</div>                             <p><?php echo ($list[0][content]); ?></p>
							
								<a href="#" class="hvr-shutter-in-vertical fuqian">付钱</a>
							
						</div>
					</div>
				<div class="clearfix"> </div>
				
				</div>
				
				<div class="clearfix"> </div>
		</div>
	</div>
		<!---->
		
</body>
</html>
<script>
$("#gnumjia").click(function(){
var sum =Number($("#ark_buyqn").val());
var num=Number($("#num").html());
if (sum==num) {
alert('没货');
}else{
	var gsum =sum+1;
    var price = $('#price').html();
    var sumprice = price * gsum;
    $('#ark_buyqn').val(gsum);
    $('.g-total-price').html(sumprice);
}
});
$("#gnumjian").click(function(){
	// alert(111);
var sum =Number($("#ark_buyqn").val());
if (sum==1) {
	 alert('购买数量是1的正整数倍');
	}else{
		var gsum =sum-1;
    var price = $('#price').html();
    var sumprice = price * gsum;
    $('#ark_buyqn').val(gsum);
    $('.g-total-price').html(sumprice);
	}    
});

$("#ark_buyqn").keyup(function(){

    var sum = Number($("#ark_buyqn").val());
    var num=Number($("#num").html());
    var price = $('#price').html();
    var sumprice = price * sum;
    var r = /^[0-9]*[1-9][0-9]*$/
    if(!r.test(sum)){
        alert('购买数量是1的正整数倍');
        $('#ark_buyqn').val(1);
        $('.g-total-price').html(price);
    }else{
        $('.g-total-price').html(sumprice);  	
 }
    
 })
// 添加购物车
$('#addcart').click(function(){
	// alert(455);
	var gid = <?php echo ($list[0]['id']); ?>;
	var sum = Number($("#ark_buyqn").val());
    var price = $('#price').html();
    var sumprice = $('.g-total-price').html();
    var attrvid = new Array();
    $('select').each(function(k,v){
        attrvid.push($(v).val());
          // alert($(v).val());
    });
    attrvid.sort(function(a,b){
    	return a-b;
    });
   // alert(attrvid);
   // alert(gid);
   // alert(sum);
   // alert(sumprice);
   // alert(price);
   var url = "<?php echo U('Cart/add');?>";
    $.post(url, { gid:gid, attrvid:attrvid, sum:sum, sumprice:sumprice, price:price },
    	// alert(1);
        function(data){
            if(data.status==1){
            	alert(data.info);
                $('#cartnum').html(1+cartnum);
            }else{
                window.location.href = '<?php echo U('User/login');?>';
            }
        });      

});


</script>